<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/1
 * Time: 15:41
 */
namespace  app\blogadmin\model;

use think\Db;
use think\Model;
use think\Request;


class Power extends Model{
    protected $_table='admin_power';

    /**
     * 获取登录者的信息
     * @param $data
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getAllpower(){
        $res=Db::table($this->_table)->select();
        return $res;
    }

    /**
     * 获取所有的用户数据
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getAllAdmin(){
        $res=Db::table($this->_table)->order('id ASC')->select();
        return $res;
    }

    /**
     * 添加数据
     * @param $data
     * @return bool
     */
    public function add($data){
        $res=Db::table($this->_table)->insert($data);
        if($res)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    /**
     * 根据条件查找一条数据
     * @param $data
     * @return bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function  getOne($data){
        $res=Db::table($this->_table)->where($data)->find();
        if($res){
            return $res;
        }else{
            return false;
        }
    }

    /**
     * 根据id 删除数据
     * @param $id
     * @return bool
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function del($id){
        $res=Db::table($this->_table)->delete($id);
        if($res)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public function upda($data){
        $res=Db::table($this->_table)->update($data);
        if($res){
            return $res;
        }else{
            return false;
        }
    }






}